﻿using System;

namespace BusinessLayer.Tools
{
    /// <summary>
    /// Helper class to fix user-editable pathes
    /// </summary>
    public class PathesHelper
    {
        /// <summary>
        /// Fixes the path to solution folder.
        /// </summary>
        /// <param name="currentPath">The current path.</param>
        /// <returns>Fixed path.</returns>
        public static String FixSolutionPath(string currentPath)
        {
            if (string.IsNullOrEmpty(currentPath))
            {
                return string.Empty;
            }
            return currentPath.EndsWith("\\") ? currentPath : string.Concat(currentPath,"\\");
        }

        /// <summary>
        /// Fixes the path to logs folder.
        /// </summary>
        /// <param name="currentPath">The current path.</param>
        /// <param name="createSubFolder">if set to <c>true</c> will add additional DeploymentLogs\ string as a subfolder.</param>
        /// <returns>Fixed path.</returns>
        public static string FixLogsPath(string currentPath, bool createSubFolder)
        {
            if (string.IsNullOrEmpty(currentPath))
            {
                return string.Empty;
            }
            var fixedPath = currentPath.EndsWith("\\")
                ? currentPath
                : string.Concat(currentPath, "\\");

            return createSubFolder ? string.Concat(fixedPath, "DeploymentLogs\\") : fixedPath;
        }
    }
}
